package com.byd.web.controller.editor;

import com.byd.system.domain.SysUser;
import com.byd.system.page.PageBean;
import com.byd.web.common.R;
import com.byd.web.service.IActivitiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("service/editor")
public class EditorSelectResource {
    @Resource
    private IActivitiService activitiService;

    @RequestMapping(value = "/idUser/list", method = RequestMethod.POST, produces = "application/json")
    @ResponseStatus(value = HttpStatus.OK)
    public PageBean<SysUser> userList(@RequestParam Integer pageNum,
                                      @RequestParam Integer pageSize,
                                      @RequestParam Integer groupType,
                                      @RequestParam String groupId) {
        return activitiService.queryUserPage(pageNum, pageSize, groupType, groupId);
    }

    @RequestMapping(value = "/idGroup/deptTree", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.OK)
    public R<?> getDeptTree() {
        return R.ok(activitiService.getDeptList());
    }

    @RequestMapping(value = "/idGroup/postTree", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.OK)
    public R<?> getPostTree() {
        return R.ok(activitiService.getPostList());
    }

    @RequestMapping(value = "/idGroup/roleTree", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.OK)
    public R<?> getRoleTree() {
        return R.ok(activitiService.getRoleList());
    }

    @RequestMapping(value = "/idGroup/getPostByDept", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.OK)
    public R<?> getPostByDept(Long deptId) {
        return R.ok(activitiService.getPostByDept(deptId));
    }

}
